package com.ruoyi.siyun.service.impl;


import java.util.Date;
import java.util.List;


import com.ruoyi.common.core.domain.entity.SyAppUsers;
import com.ruoyi.siyun.domain.SyAppBlacklist;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.siyun.mapper.SyAppUsersMapper;
import com.ruoyi.siyun.service.ISyAppUsersService;
import org.springframework.transaction.annotation.Transactional;

/**
 * app用户Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-23
 */
@Service
public class SyAppUsersServiceImpl implements ISyAppUsersService 
{
    @Autowired
    private SyAppUsersMapper syAppUsersMapper;

    /**
     * 查询app用户
     * 
     * @param id app用户主键
     * @return app用户
     */
    @Override
    public SyAppUsers selectSyAppUsersById(Long id)
    {
        return syAppUsersMapper.selectSyAppUsersById(id);
    }

    /**
     * 查询app用户列表
     * 
     * @param syAppUsers app用户
     * @return app用户
     */
    @Override
    public List<SyAppUsers> selectSyAppUsersList(SyAppUsers syAppUsers)
    {
        return syAppUsersMapper.selectSyAppUsersList(syAppUsers);
    }

    /**
     * 新增app用户
     * 
     * @param syAppUsers app用户
     * @return 结果
     */
    @Override
    public int insertSyAppUsers(SyAppUsers syAppUsers)
    {
        return syAppUsersMapper.insertSyAppUsers(syAppUsers);
    }

    /**
     * 修改app用户
     * 
     * @param syAppUsers app用户
     * @return 结果
     */
    @Override
    public int updateSyAppUsers(SyAppUsers syAppUsers)
    {
        return syAppUsersMapper.updateSyAppUsers(syAppUsers);
    }

    /**
     * 批量删除app用户
     * 
     * @param ids 需要删除的app用户主键
     * @return 结果
     */
    @Override
    public int deleteSyAppUsersByIds(Long[] ids)
    {
        return syAppUsersMapper.deleteSyAppUsersByIds(ids);
    }

    /**
     * 删除app用户信息
     * 
     * @param id app用户主键
     * @return 结果
     */
    @Override
    public int deleteSyAppUsersById(Long id)
    {
        return syAppUsersMapper.deleteSyAppUsersById(id);
    }
    /**
     * 更新app用户状态
     */
    @Override
    public int updateSyAppUsersStatus(SyAppUsers syAppUsers) {
        // 实现更新状态的逻辑
        return syAppUsersMapper.updateSyAppUsersStatus(syAppUsers);
    }

    @Override
    public int resetAppPwd(SyAppUsers user) {
        return syAppUsersMapper.updateUser(user);
    }


    //    public void insertSyAppBlacklist(SyAppBlacklist syAppBlacklist) {
//        List<SyAppBlacklist> syAppBlacklistList = syAppUsers.getSyAppBlacklistList();
//        Long id = syAppUsers.getId();
//        if (StringUtils.isNotNull(syAppBlacklistList))
//        {
//            List<SyAppBlacklist> list = new ArrayList<SyAppBlacklist>();
//            for (SyAppBlacklist syAppBlacklist : syAppBlacklistList)
//            {
//                syAppBlacklist.setUserId(id);
//                list.add(syAppBlacklist);
//            }
//            if (list.size() > 0)
//            {
//                syAppUsersMapper.batchSyAppBlacklist(list);
//            }
//        }
//    }
    @Override
    @Transactional
    public int insertBlacklistByAppUserId(SyAppBlacklist syAppBlacklist) {
        syAppBlacklist.setCreateTime(new Date());
        syAppBlacklist.setUpdateTime(new Date());
        return syAppUsersMapper.insertBlacklistByAppUserId(syAppBlacklist);
    }

    @Override
    public SyAppUsers selectUserByUserName(String username) {
        SyAppUsers syAppUsers = syAppUsersMapper.selectSyAppUsersByusername(username);
        return syAppUsers;
    }


}
